<template>
  <a-modal v-model="visible"   :title="title"  @cancel='cancel' @ok='sure'>
    <a-form-model :model="item" :label-col="{span :4 }" :wrapper-col="{ span: 20 }">
      <a-form-model-item label="诉求" required>
        <a-input v-model="item.content"   type="textarea" :auto-size="{ minRows: 5 ,maxRows: 5}"/>
      </a-form-model-item>
      <a-form-model-item label="说明" required>
        <a-input v-model="item.contentExplain" type="textarea" :auto-size="{ minRows: 5 ,maxRows: 5}"/>
      </a-form-model-item>
    </a-form-model>
  </a-modal>
</template>

<script>
import ReportsEpidemicDailyService from '@/myService/ReportsEpidemicDailyService'

export default {
  name: 'HandleOrderEditModel',
  props:['ds'],
  data(){
    return{
      visible:false,
      title:'',
      item:{},
      flag:false,
    }
  },
  methods:{
    open(title,item){
      this.title=title;
      if(item!==null){
        this.item=item;
        this.flag=true;
      }
      else {
        this.item={
        }
        this.flag=false;
      }
      this.visible=true
    },
    async cancel() {
      this.$emit("update")
      this.visible = false;
    },
    sure(){
      if(this.item.content==='' || this.item.content===undefined
        || this.item.contentExplain==='' || this.item.contentExplain===undefined){
        this.$message.error("诉求、说明不可为空")
        return;
      }
      let data;
      if(this.flag){
        data={
          id:this.item.id,
          content:this.item.content,
          contentExplain:this.item.contentExplain,
          ds:this.ds
        }
      }else {
        data={
          id:"",
          content:this.item.content,
          contentExplain:this.item.contentExplain,
          ds:this.ds
        }
      }
      ReportsEpidemicDailyService.editHandleOrder(data).then(res=>{
        if(res.result===true){
          if(this.flag){
            this.$message.success("更新成功")
          }else {
            this.$message.success("添加成功")
          }
          this.cancel()
        }
      })

    }
  }
}
</script>

<style scoped>

</style>